package com.controller;

import com.result.Result;
import com.service.StatisticService;
import com.utils.DateUtil;
import com.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;

/**
 * @Author: chihaojie
 * @Date: 2019/6/22 16:12
 * @Version 1.0
 * @Note  统计相关接口
 */

@Api(value = "statisticApi")
@CrossOrigin
@RestController
@RequestMapping("/statistic")
public class StatisticController {



    @Autowired
    private StatisticService  statisticService;

    @ApiOperation(value = "按整体日总销量统计", httpMethod = "GET", notes = "按整体日总销量统计")
    @RequestMapping(value = "/getWholeDailySaleStatistic", method = RequestMethod.GET)
    public Result<WholeDailySaleVO> getWholeDailySaleStatistic(@RequestParam(value = "day") Long  day, HttpServletRequest request, HttpServletResponse response) {
        Date date=new Date(day);
        return statisticService.getWholeDailySaleStatistic(date,request,response);
    }

    @ApiOperation(value = "按整体月总销量统计", httpMethod = "GET", notes = "按整体月总销量统计")
    @RequestMapping(value = "/getWholeMonthSaleStatistic", method = RequestMethod.GET)
    public Result<WholeMonthSaleVO> getWholeMonthSaleStatistic(@RequestParam(value = "month") Long month, HttpServletRequest request, HttpServletResponse response) {
        return statisticService.getWholeMonthSaleStatistic(month,request,response);
    }

    @ApiOperation(value = "按整体日总销量统计2", httpMethod = "GET", notes = "按整体日总销量统计2")
    @RequestMapping(value = "/getDailySaleStatistic", method = RequestMethod.GET)
    public Result<List<WholeDailySaleVO>> getDailySaleStatistic(@RequestParam(value = "startTime") Long  startTime,
                                                                @RequestParam(value = "endTime") Long  entTime ,
                                                                 HttpServletRequest request, HttpServletResponse response) {
        return statisticService.getDailySaleStatistic(startTime,entTime,request,response);
    }

    @ApiOperation(value = "按整体月总销量统计2", httpMethod = "GET", notes = "按整体月总销量统计2")
    @RequestMapping(value = "/getMonthlySaleStatistic", method = RequestMethod.GET)
    public Result<List<WholeMonthSaleVO>> getMonthlySaleStatistic(@RequestParam(value = "startTime") Long  startTime,
                                                                  @RequestParam(value = "endTime") Long  entTime ,
                                                                  HttpServletRequest request, HttpServletResponse response) {
        return statisticService.getMonthlySaleStatistic(startTime,entTime,request,response);
    }






    @ApiOperation(value = "代理商所有商品SKU销量统计", httpMethod = "GET", notes = "代理商所有商品SKU销量统计")
    @RequestMapping(value = "/getAgentAllProductSKUSaleStatistic", method = RequestMethod.GET)
    public Result<List<ProductSKUSaleVO>> getAgentAllProductSKUSaleStatistic(@RequestParam(value = "startTime") Long  startTime,
                                                                          @RequestParam(value = "endTime") Long  entTime ) {
        return statisticService.getAgentAllProductSKUSaleStatistic(startTime,entTime);
    }

    @ApiOperation(value = "代理商单个商品SKU日销量统计", httpMethod = "GET", notes = "代理商单个商品SKU日销量统计")
    @RequestMapping(value = "/getAgentSingleSKUDaySaleStatistic", method = RequestMethod.GET)
    public Result<List<ProductSKUSaleVO>> getAgentSingleSKUDaySaleStatistic(@RequestParam(value = "productId") Long productId,
                                                                             @RequestParam(value = "startTime") Long  startTime,
                                                                             @RequestParam(value = "endTime") Long  entTime) {
        return statisticService.getAgentSingleSKUDaySaleStatistic(productId,startTime,entTime);
    }

    //月销售统计ProductSKUMonthSaleVO
    @ApiOperation(value = "代理商单个商品SKU月销量统计", httpMethod = "GET", notes = "代理商单个商品SKU月销量统计")
    @RequestMapping(value = "/getAgentSingleSKUMonthSaleStatistic", method = RequestMethod.GET)
    public Result<List<ProductSKUMonthSaleVO>> getAgentSingleSKUMonthSaleStatistic(@RequestParam(value = "productId") Long productId,
                                                                            @RequestParam(value = "startTime") Long  startTime,
                                                                            @RequestParam(value = "endTime") Long  entTime) {
        return statisticService.getAgentSingleSKUMonthSaleStatistic(productId,startTime,entTime);
    }


    /**
     * 设备
     */
    @ApiOperation(value = "代理商所有设备销量统计", httpMethod = "GET", notes = "代理商所有设备销量统计")
    @RequestMapping(value = "/getAgentAllDeviceSaleStatistic", method = RequestMethod.GET)
    public Result<List<SingleDeviceSaleVO>> getAgentAllDeviceSaleStatistic(@RequestParam(value = "startTime") Long  startTime,
                                                                             @RequestParam(value = "endTime") Long  entTime ) {
        return statisticService.getAgentAllDeviceSaleStatistic(startTime,entTime);
    }

    @ApiOperation(value = "代理商单个设备日销量统计", httpMethod = "GET", notes = "代理商单个设备日销量统计")
    @RequestMapping(value = "/getAgentSingleDeviceDaySaleStatistic", method = RequestMethod.GET)
    public Result<List<SingleDeviceDaySaleVO>> getAgentSingleDeviceDaySaleStatistic(@RequestParam(value = "deviceId") Long deviceId,
                                                                            @RequestParam(value = "startTime") Long  startTime,
                                                                            @RequestParam(value = "endTime") Long  entTime) {
        return statisticService.getAgentSingleDeviceDaySaleStatistic(deviceId,startTime,entTime);
    }

    //月销售统计ProductSKUMonthSaleVO
    @ApiOperation(value = "代理商单个商品SKU月销量统计", httpMethod = "GET", notes = "代理商单个商品SKU月销量统计")
    @RequestMapping(value = "/getAgentSingleDeviceMonthSaleStatistic", method = RequestMethod.GET)
    public Result<List<SingleDeviceMonthSaleVO>> getAgentSingleDeviceMonthSaleStatistic(@RequestParam(value = "deviceId") Long deviceId,
                                                                                   @RequestParam(value = "startTime") Long  startTime,
                                                                                   @RequestParam(value = "endTime") Long  entTime) {
        return statisticService.getAgentSingleDeviceMonthSaleStatistic(deviceId,startTime,entTime);
    }


    /**
     * 医院销售统计
     */
    @ApiOperation(value = "代理商所有设备销量统计", httpMethod = "GET", notes = "代理商所有设备销量统计")
    @RequestMapping(value = "/getAgentAllHospitalSaleStatistic", method = RequestMethod.GET)
    public Result<List<SingleHospitalSaleVO>> getAgentAllHospitalSaleStatistic(@RequestParam(value = "startTime") Long  startTime,
                                                                           @RequestParam(value = "endTime") Long  entTime ) {
        return statisticService.getAgentAllHospitalSaleStatistic(startTime,entTime);
    }


    @ApiOperation(value = "代理商单个医院日销量统计", httpMethod = "GET", notes = "代理商单个医院日销量统计")
    @RequestMapping(value = "/getAgentSingleHospitalDaySaleStatistic", method = RequestMethod.GET)
    public Result<List<SingleHospitalDaySaleVO>> getAgentSingleHospitalDaySaleStatistic(@RequestParam(value = "hospitalId") Long hospitalId,
                                                                                    @RequestParam(value = "startTime") Long  startTime,
                                                                                    @RequestParam(value = "endTime") Long  entTime) {
        return statisticService.getAgentSingleHospitalDaySaleStatistic(hospitalId,startTime,entTime);
    }

    //月销售统计ProductSKUMonthSaleVO
    @ApiOperation(value = "代理商单个医院月销量统计", httpMethod = "GET", notes = "代理商单个医院月销量统计")
    @RequestMapping(value = "/getAgentSingleHospitalMonthSaleStatistic", method = RequestMethod.GET)
    public Result<List<SingleHospitalMonthSaleVO>> getAgentSingleHospitalMonthSaleStatistic(@RequestParam(value = "hospitalId") Long hospitalId,
                                                                                        @RequestParam(value = "startTime") Long  startTime,
                                                                                        @RequestParam(value = "endTime") Long  entTime) {
        return statisticService.getAgentSingleHospitalMonthSaleStatistic(hospitalId,startTime,entTime);
    }



}
